//
//  XBMenuCell.m
//  TXBPlatform
//
//  Created by HX on 2017/8/31.
//  Copyright © 2017年 TXB. All rights reserved.
//

#import "XBMenuCell.h"

@interface XBMenuCell()
{
     ASImageNode *_imageNode;
     ASTextNode *_textNode;
}

@end

@implementation XBMenuCell

- (instancetype)init
{
     self = [super init];
     if (self) {

          _imageNode = [[ASImageNode alloc] init];
          _imageNode.image = [UIImage imageNamed:@"icon"];
          [self addSubnode:_imageNode];

          _textNode = [[ASTextNode alloc] init];
          _textNode.attributedText = [[NSAttributedString alloc] initWithString:@"ABC"];
          [self addSubnode:_textNode];
     }
     return self;
}

- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
     ASStackLayoutSpec *spec =
     [ASStackLayoutSpec
      stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
      spacing:5.0
      justifyContent:ASStackLayoutJustifyContentStart
      alignItems:ASStackLayoutAlignItemsStart
      children:@[_imageNode, _textNode]];
     spec.style.minWidth = ASDimensionMakeWithPoints(60.0);
     spec.style.maxHeight = ASDimensionMakeWithPoints(40.0);

     return spec;
}



- (void)didLoad
{
          // enable highlighting now that self.layer has loaded -- see ASHighlightOverlayLayer.h
     self.layer.as_allowsHighlightDrawing = YES;

     [super didLoad];
}

@end
